import request from '@/utils/request'

// 查询维保机构人员列表
export function getUserList(type) {
  return request({
    url: `/org/user/list/${type}`,
    method: 'get'
  })
}

// 获取维保项目计划列表
export function getProjectPlanByCustomerId(customerId, params) {
  return request({
    url: `/org/project/projectPlanByCustomerId/${customerId}`,
    method: 'get',
    params
  })
}



// 获取维保项目详细
export function getProjectPlanInfoSubPlanId(subPlanId) {
  return request({
    url: `/org/project/projectPlanInfo/${subPlanId}`,
    method: 'get'
  })
}

// 获取维保项目计划任务列表条件//系统
export function getPlanTaskListQuery(subPlanId) {
  return request({
    url: `/org/project/planTaskListQuery/${subPlanId}`,
    method: 'get'
  })
}


// 获取维保项目计划包含建筑列表
export function getProjectPlanBuildingList(subPlanId) {
  return request({
    url: `/org/project/projectPlanBuildingList/${subPlanId}`,
    method: 'get'
  })
}



// 获取建筑的楼层任务列表
export function getBuildingPlanTaskList(params) {
  return request({
    url: `/org/project/buildingPlanTaskList`,
    method: 'get',
    params
  })
}


//获层楼层的设备任务列表
export function getDevicePlanTaskList(params) {
  return request({
    url: `/org/project/devicePlanTaskList`,
    method: 'get',
    params
  })
}

//获取包含子计划的总计划列表
export function getPlanList(params) {
  return request({
    url: `/manager/plan/plan/list`,
    method: 'get',
    params
  })
}

// 查询列表
export function getProjectCountAndBuildingCountList(params) {
  return request({
    url: `/org/project/customer/projectCountAndBuildingCountList`,
    method: 'get',
    params
  })
}


// 查询指定客户的项目
export function getListByCustomerId(id) {
  return request({
    url: `/org/project/listByCustomerId/${id}`,
    method: 'get'
  })
}

//总后台日程查询项目参与人员
export function getProjectUsers(id) {
  return request({
    url: `/org/schedule/manage/getProjectUsers/${id}`,
    method: 'get'
  })
}


//总后台按月展示日程
export function getSchedulesList(id, params) {
  return request({
    url: `/org/schedule/manage/getSchedules/${id}`,
    method: 'get',
    params
  })
}

//导出获取包含子计划的总计划列表
export function exPortPlanList(data) {
  return request({
    url: `/manager/plan/plan/list/export`,
    method: 'post',
    data,
    responseType: 'blob',
  })
}

// 获取维保记录详情
export function getRecordListDetails(params) {
  return request({
    url: `/manager/plan/recordListDetails`,
    method: 'get',
    params
  })
}

//建筑的楼层任务列表导出
// /?buildingId=${data.buildingId}&deviceId=${data.deviceId}&subPlanId=${data.subPlanId}&systemId=${data.systemId}
export function exPortBuildingPlanTaskList(data) {
  let url = `/org/project/buildingPlanTaskList/export/?buildingId=${data.buildingId}&subPlanId=${data.subPlanId}`

  if (data.deviceId !== null && data.deviceId !== undefined) {
    // 如果存在，则将a的值添加到URL查询参数中  
    url += `&deviceId=${encodeURIComponent(data.deviceId)}`;
  }
  if (data.systemId !== null && data.systemId !== undefined) {
    // 如果存在，则将a的值添加到URL查询参数中  
    url += `&systemId=${encodeURIComponent(data.systemId)}`;
  }
  return request({
    url,
    method: 'post',
    data,
    responseType: 'blob',
  })
}


